home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / t_sys5 / 92052tar.gz / 920528.tar / netrom.h < prev    next >
C/C++ Source or Header  |  1992-01-13  |  6KB  |  140 lines

  1. /* @(#) $Header: netrom.h,v 1.13 92/01/12 18:40:16 deyke Exp $ */
  2.  
  3. #ifndef _NETROM_H
  4. #define _NETROM_H
  5.  
  6. #ifndef _MBUF_H
  7. #include "mbuf.h"
  8. #endif
  9.  
  10. #ifndef _IFACE_H
  11. #include "iface.h"
  12. #endif
  13.  
  14. #ifndef _AX25_H
  15. #include "ax25.h"
  16. #endif
  17.  
  18. #ifndef _GLOBAL_H
  19. #include "global.h"
  20. #endif
  21.  
  22. #ifndef _TIMER_H
  23. #include "timer.h"
  24. #endif
  25.  
  26. #ifndef _SESSION_H
  27. #include "session.h"
  28. #endif
  29.  
  30. #define NR3HLEN         15      /* length of a net/rom level 3 hdr, */
  31. #define NR3DLEN         241     /* max data size in net/rom l3 packet */
  32. #define NR3NODESIG      0xff    /* signature for nodes broadcast */
  33. #define NR3NODEHL       7       /* nodes bc header length */
  34.  
  35. #define NRRTDESTLEN     21      /* length of destination entry in */
  36.                 /* nodes broadcast */
  37. #define NRDESTPERPACK   11      /* maximum number of destinations per */
  38.                 /* nodes packet */
  39.  
  40. /* NET/ROM protocol numbers */
  41. #define NRPROTO_IP      0x0c
  42.  
  43. /* Round trip timing parameters */
  44. #define AGAIN   8               /* Average RTT gain = 1/8 */
  45. #define DGAIN   4               /* Mean deviation gain = 1/4 */
  46.  
  47. #define NR4MAXINFO      236     /* Maximum data in an info packet */
  48. #define NR4MINHDR       5       /* Minimum length of NET/ROM transport header */
  49.  
  50. #define NR4OPPID        0       /* Protocol ID extension to network layer */
  51. #define NR4OPCONRQ      1       /* Connect request */
  52. #define NR4OPCONAK      2       /* Connect acknowledge */
  53. #define NR4OPDISRQ      3       /* Disconnect request */
  54. #define NR4OPDISAK      4       /* Disconnect acknowledge */
  55. #define NR4OPINFO       5       /* Information packet */
  56. #define NR4OPACK        6       /* Information acknowledge */
  57. #define NR4OPCODE       0x0f    /* Mask for opcode nybble */
  58. #define NR4MORE         0x20    /* MORE bit */
  59. #define NR4NAK          0x40    /* NAK bit */
  60. #define NR4CHOKE        0x80    /* CHOKE bit */
  61.  
  62. struct circuit {
  63.   int  localindex;              /* Local circuit index */
  64.   int  localid;                 /* Local circuit ID */
  65.   int  remoteindex;             /* Remote circuit index */
  66.   int  remoteid;                /* Remote circuit ID */
  67.   int  outbound;                /* Circuit was created by local request */
  68.   char  node[AXALEN];           /* Call of peer node */
  69.   char  cuser[AXALEN];          /* Call of user */
  70.   int  state;                   /* Connection state */
  71. #define DISCONNECTED  0
  72. #define CONNECTING    1
  73. #define CONNECTED     2
  74. #define DISCONNECTING 3
  75.   int  reason;                  /* Reason for disconnecting */
  76. #define NORMAL        0         /* Normal disconnect */
  77. #define RESET         1         /* Disconnected by other end */
  78. #define TIMEOUT       2         /* Excessive retransmissions */
  79. #define NETWORK       3         /* Network problem */
  80.   int  window;                  /* Negotiated window size */
  81.   int  naksent;                 /* NAK has been sent */
  82.   int  chokesent;               /* CHOKE has been sent */
  83.   int  closed;                  /* Disconnect when send queue empty */
  84.   int  recv_state;              /* Incoming sequence number expected next */
  85.   int  send_state;              /* Next sequence number to be sent */
  86.   int  cwind;                   /* Congestion window */
  87.   int32 remote_busy;            /* Other end's window is closed */
  88.   int  retry;                   /* Retransmission retry count */
  89.   int32 srtt;                   /* Smoothed round trip time, milliseconds */
  90.   int32 mdev;                   /* Mean deviation, milliseconds */
  91.   struct timer timer_t1;        /* Retransmission timer */
  92.   struct timer timer_t2;        /* Acknowledgement delay timer */
  93.   struct timer timer_t3;        /* No-activity timer */
  94.   struct timer timer_t4;        /* Busy timer */
  95.   struct timer timer_t5;        /* Packet assembly timer */
  96.   struct mbuf *reseq;           /* Resequencing queue */
  97.   struct mbuf *rcvq;            /* Receive queue */
  98.   int16 rcvcnt;                 /* Receive queue length */
  99.   struct mbuf *sndq;            /* Send queue */
  100.   int32 sndqtime;               /* Last send queue write time */
  101.   struct mbuf *resndq;          /* Resend queue */
  102.   int  unack;                   /* Number of unacked frames */
  103.   int32 sndtime[256];           /* Time of 1st transmission */
  104.   void (*r_upcall) __ARGS((struct circuit *p, int cnt));
  105.                 /* Call when data arrives */
  106.   void (*t_upcall) __ARGS((struct circuit *p, int cnt));
  107.                 /* Call when ok to send more data */
  108.   void (*s_upcall) __ARGS((struct circuit *p, int oldstate, int newstate));
  109.                 /* Call when connection state changes */
  110.   char  *user;                  /* User parameter (e.g., for mapping to an
  111.                  * application control block)
  112.                  */
  113.   struct circuit *next;         /* Linked-list pointer */
  114. };
  115.  
  116. /* In netrom.c: */
  117. int isnetrom __ARGS((char *call));
  118. void new_neighbor __ARGS((char *call));
  119. int nr_send __ARGS((struct mbuf *bp, struct iface *iface, int32 gateway, int prec, int del, int tput, int rel));
  120. void nr3_input __ARGS((struct mbuf *bp, char *fromcall));
  121. char *nr_addr2str __ARGS((struct circuit *pc));
  122. struct circuit *open_nr __ARGS((char *node, char *cuser, int window, void (*r_upcall )__ARGS ((struct circuit *p, int cnt )), void (*t_upcall )__ARGS ((struct circuit *p, int cnt )), void (*s_upcall )__ARGS ((struct circuit *p, int oldstate, int newstate )), char *user));
  123. int send_nr __ARGS((struct circuit *pc, struct mbuf *bp));
  124. int space_nr __ARGS((struct circuit *pc));
  125. int recv_nr __ARGS((struct circuit *pc, struct mbuf **bpp, int cnt));
  126. int close_nr __ARGS((struct circuit *pc));
  127. int reset_nr __ARGS((struct circuit *pc));
  128. int del_nr __ARGS((struct circuit *pc));
  129. int valid_nr __ARGS((struct circuit *pc));
  130. int kick_nr __ARGS((struct circuit *pc));
  131. void nrclient_send_upcall __ARGS((struct circuit *pc, int cnt));
  132. void nrclient_recv_upcall __ARGS((struct circuit *pc, int cnt));
  133. int nr_attach __ARGS((int argc, char *argv [], void *p));
  134. int donetrom __ARGS((int argc, char *argv [], void *p));
  135. int nr4start __ARGS((int argc, char *argv [], void *p));
  136. int nr40 __ARGS((int argc, char *argv [], void *p));
  137. void netrom_initialize __ARGS((void));
  138.  
  139. #endif  /* _NETROM_H */
  140.